package cn.wizzer.app.web.modules.controllers.platform.user;

import cn.wizzer.app.user.modules.services.TrialFundService;
import cn.wizzer.framework.util.Result;
import com.alibaba.dubbo.config.annotation.Reference;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

/**
 * 体验金
 */
@IocBean
@At("/platform/user/trialFund")
public class TrialFundController {

    @Inject
    @Reference
    private TrialFundService trialFundService;

    @At("/")
    @Ok("beetl:/platform/user/trialFund/index.html")
    @RequiresPermissions("user.trialFund.list")
    public void index() {
    }

    /**
     * 查询列表（分页）
     *
     * @param userKeyword 昵称或用户名
     * @param searchDate  日期时间
     * @param pageNumber  当前页
     * @param pageSize    显示页数
     * @return
     */
    @At
    @Ok("json:full")
    @RequiresPermissions("user.trialFund.list")
    public Object data(@Param("userKeyword") String userKeyword,
                       @Param("searchDate") String[] searchDate,
                       @Param("pageNumber") int pageNumber,
                       @Param("pageSize") int pageSize) {
        return Result.success().addData(trialFundService.listPage(userKeyword, searchDate, pageNumber, pageSize));
    }

    /**
     * 删除申请记录
     *
     * @param id
     * @return
     */
    @At("/delete/?")
    @Ok("json:full")
    @RequiresPermissions("user.trialFund.delete")
    public Object delete(String id) {
        trialFundService.delete(id);
        return Result.success();
    }


}
